package com.sxy.json;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

/**
 * @author 宋鑫宇
 * @version 1.0
 */
public class FastJsonDemo {
    public static void main(String[] args) {
        User user = new User();
        user.setId(1);
        user.setUsername("zhangsan");
        user.setPassword("123");
        //1.将java对象转为json字符串
        String s = JSON.toJSONString(user);
        System.out.println(s);
        //2.将json字符串转为java对象
        User user1 = JSON.parseObject(s, User.class);
        System.out.println(user1);
    }
}
